package com.ruike.alisurface.ui.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ruike.alisurface.R;
import com.ruike.alisurface.bean.CarGoodsBeans;
import com.voodoo.lib_logcat.L;
import com.voodoo.lib_utils.imageLoader.GlideImageLoader;

import java.util.List;

public class ShopPayAdapter extends BaseQuickAdapter<CarGoodsBeans, BaseViewHolder> {
    Context mContext;

    public ShopPayAdapter(@LayoutRes int layoutResId, @Nullable List<CarGoodsBeans> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, CarGoodsBeans item) {

        L.i("数据==" + item.toString());
        ImageView productimg = helper.getView(R.id.pay_productimg_img);
        TextView productname = helper.getView(R.id.pay_productname_tv);
        TextView price = helper.getView(R.id.pay_price_tv);
        helper.setText(R.id.spec_tv, item.getSpec());

        GlideImageLoader.getInstance().loadImage(mContext, item.getProductimg(), productimg);
        productname.setText(item.getProductname());
        price.setText("￥ " + item.getPrice());

        if (item.getIs_remote() == 1) {
            helper.getView(R.id.pay_is_remote_tv).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.pay_is_remote_tv).setVisibility(View.GONE);
        }

        if (item.getIs_insurance() == 1) {
            helper.getView(R.id.pay_is_insurance_tv).setVisibility(View.VISIBLE);

        } else {
            helper.getView(R.id.pay_is_insurance_tv).setVisibility(View.GONE);
        }

        if (item.getIs_true_name() == 1) {
            helper.getView(R.id.pay_is_true_name_tv).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.pay_is_true_name_tv).setVisibility(View.GONE);
        }
        if (item.getIs_prescription() == 1) {
            helper.getView(R.id.pay_is_true_prescription_tv).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.pay_is_true_prescription_tv).setVisibility(View.GONE);
        }
        //获取当前item的position
        //int position = helper.getLayoutPosition();
    }

}

